@extends("admin.layout.main")

@section("content")

    <style>
        table thead tr th {
            text-align: center
        }

        table tbody tr td {
            text-align: center
        }
    </style>
    <div class="page-header">
        <h1>
            管理员
        </h1>
    </div>
    <div class="page-header">
        <form action="">
            <a href="{{ route('admin.platform.addAdmin') }}" class="btn btn-xs btn-primary">新增管理员</a>
            <div style="float: right">
                <input type="text" name="keyword" value="{{ $where['keyword'] }}" placeholder="请输入登录帐号">
                <label>职务：
                    <select name="position">
                        <option value="0">全部</option>
                        @foreach($roleList as $v)
                            <option value="{{ $v->id }}"
                                    @if($v->id == $where['position']) selected @endif >{{ $v->name }}</option>
                        @endforeach
                    </select>
                </label>
                <label>帐号状态：
                    <select name="status">
                        <option value="">全部</option>
                        <option value="0" @if($where['status']==0) selected @endif>正常</option>
                        <option value="1" @if($where['status']==1) selected @endif>禁用</option>
                    </select>
                </label>
                <a>
                    <button class="btn btn-xs btn-primary">搜索</button>
                </a>
            </div>
        </form>
    </div>


    <!-- div.table-responsive -->

    <!-- div.dataTables_borderWrap -->
    <div>
        <table id="" class="table table-striped table-bordered table-hover">
            <thead>
            <tr>
                <th>序号</th>
                {{--<th>姓名</th>--}}
                <th>登录帐号</th>
                <th>职务</th>
                {{--<th>手机号码</th>--}}
                <th>最近登录时间</th>
                <th>帐号状态</th>
                <th>操作</th>
            </tr>
            </thead>

            <tbody>
            @foreach($data as $v)
                <tr>
                    <td>{{ $v->id }}</td>
                    {{--<td>{{ $v->admin_name }}</td>--}}
                    <td>{{ $v->admin_name }}</td>
                    <td>{{ $v->role['name'] }}</td>
                    {{--<td>{{ $v->mobile }}</td>--}}
                    <td>{{ $v->updated_at }}</td>
                    <td>@if($v->status==0) 正常 @else 禁用 @endif</td>
                    <td>
                        @if($v->id != 1)
                            <div class="hidden-sm hidden-xs action-buttons">
                                <a class="btn btn-xs btn-primary"
                                   href="{{ route('admin.platform.editAdmin',['id'=>$v->id]) }}">查看</a>
                                <a data-id="{{ $v->id }}" data-status="{{ $v->status }}" class="btn btn-xs btn-yellow" onclick="confirm_handle('确认@if($v->status==0)禁用@else启用@endif{{ $v->admin_name }}吗？',changeStatus,'',this)">
                                    @if($v->status==0)
                                        禁用@else启用@endif
                                </a>
                                <a data-id="{{ $v->id }}" class="btn btn-xs btn-danger"
                                   onclick="confirm_handle('确认删除{{ $v->admin_name }}吗？',del,'',this)">删除</a>
                            </div>
                            <div class="hidden-md hidden-lg">
                                <div class="inline pos-rel">
                                    <button class="btn btn-minier btn-primary dropdown-toggle" data-toggle="dropdown"
                                            data-position="auto">
                                        <i class="ace-icon fa fa-cog icon-only bigger-110"></i>
                                    </button>

                                    <ul class="dropdown-menu dropdown-only-icon dropdown-yellow dropdown-menu-right dropdown-caret dropdown-close">
                                        <li>
                                            <a href="{{ route('admin.platform.editAdmin',['id'=>$v->id]) }}"
                                               class="tooltip-info" data-rel="tooltip" title="查看">
                                        <span class="blue">
                                            查看
                                        </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a data-id="{{ $v->id }}" data-status="{{ $v->status }}" onclick="confirm_handle('确认@if($v->status==0)禁用@else启用@endif{{ $v->admin_name }}吗？',changeStatus,'',this)" class="tooltip-success" data-rel="tooltip" title="启用">
                                        <span class="orange">
                                            @if($v->status==0)禁用@else启用@endif
                                        </span>
                                            </a>
                                        </li>

                                        <li>
                                            <a data-id="{{ $v->id }}" onclick="confirm_handle('确认删除{{ $v->admin_name }}吗？',del,'',this)"
                                               class="tooltip-error" data-rel="tooltip" title="删除">
                                        <span class="red">
                                            删除
                                        </span>
                                            </a>
                                        </li>
                                    </ul>
                                </div>
                            </div>
                        @endif
                    </td>
                </tr>
            @endforeach
            </tbody>
        </table>
        <div class="pagination pagination-centered">
            {{ $data->appends($where)->links('admin.layout.page') }}
        </div>
    </div>
    <script src="{{ config('global.assets_path') }}js/jquery.validate.min.js"></script>
    <script src="{{ config('global.assets_path') }}js/messages_zh.js"></script>
    <script src="/plugins/layui/layui.js"></script>
    <script src="/plugins/layui/layui_component.js"></script>
    <script src="/js/ajax.js"></script>
    <script>
        function changeStatus(obj) {
            var id = $(obj).data("id");
            var status = $(obj).data("status");
            var data = {'id': id, 'status': status};
            var url = '{{ route('admin.platform.ajaxChangeStatus') }}';
            ajaxRequest(data, url, 'post');
        }

        function del(obj) {
            var id = $(obj).data("id");
            var data = {'id': id};
            var url = '{{ route('admin.platform.ajaxDelAdmin') }}';
            ajaxRequest(data, url, 'post');
        }
    </script>
@endsection